-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: parse pattern matching #13572
base: main
Are you sure you want to change the base?
WIP: parse pattern matching #13572
Conversation
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/48511/ |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 79e5c87:
|
this.hasPlugin("patternMatching") && | ||
!this.hasFollowingLineBreak() | ||
) { | ||
return this.parseMaybeMatchExpression(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is a "primary" expression?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, i'm not super sure about this part. i would expect match () {}
to be allowed anywhere any other expression is currently allowed (nested inside the pin operator in another match construct, of course, it would only be allowed with parens)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I have open tc39/proposal-pattern-matching#214 and let's continue there.
@fedeci Good question! Yes, a match call expression
If a match call is not ambiguous, |
Both examples in #13572 (comment) should indeed be parsed as a match expression, since |
@ljharb Will it be matched like this? match (x, y) {
when ({ j }, k) { }
} |
|
b4a7cc7
to
bc04533
Compare
Note that in addition to combinatory likely using |
Great, that will simplify the parsing. |
bc04533
to
79e5c87
Compare
WIP: adding it here just to keep track of things to do and of what have been done.
&
and|
at the same level (e.g.when ({ x: 200 | 201 & 300 }) {}
)CallExpression
+BlockStatement
for newline aftermatch
MatchExpression
UnaryExpression
s asMatchPattern
with
andas